package edu.kjxy.demo0329;

import java.util.Arrays;

public class Myfuncs {

	//可变参数列表,参数本质上是一个数组
	public static Integer[] findMax(int... data) {
		if(data == null || data.length == 0)
			throw new RuntimeException("参数为0，无法处理");
		int max = data[0];
		int min = data[0];
		
		for (int i = 1; i < data.length; i++) {
			if(data[i] > max) max = data[i];
			if(data[i] < min) min = data[i];
		}
		
		Integer[] retval = {min, max};
		return retval;
	}
	
	public static int square(int n) {
		n = n * n;
		System.out.println("里面：" + n);
		return n;
	}
	public static int[] square(int[] a) {
		for (int i = 0; i < a.length; i++) {
			a[i] = a[i] * a[i];
		}
		System.out.println("里面：" + Arrays.toString(a));
		return a;
	}

}
